using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CollegeShop.Infrastructure.Entities.Repository;

namespace CollegeShop.Infrastructure.Entities.Entity
{
    public class Purchase : IAccessible<T_Purchase, Purchase>, ILogicEntity<T_Purchase, Purchase>
    {
        public int ID { get; set; }

        public string PurchaseNumber { get; set; }

        public int ProviderID { get; set; }

        public int SumAmount { get; set; }

        public decimal SumMoney { get; set; }

        public int State { get; set; }

        public string Remark { get; set; }

        public string CreateUser { get; set; }

        public DateTime CreateTime { get; set; }

        public string AuditUser { get; set; }

        public DateTime AuditTime { get; set; }

        public DateTime CompleteTime { get; set; }

        public decimal PayedMoney { get; set; }

        protected override void Covariant(T_Purchase model)
        {
            if (model != null)
            {
                    this.ID = model.ID;
                    this.PurchaseNumber = model.PurchaseNumber;
                    this.ProviderID = model.ProviderID;
                    this.SumAmount = model.SumAmount;
                    this.SumMoney = model.SumMoney;
                    this.State = model.State;
                    this.Remark = model.Remark;
                    this.CreateUser = model.CreateUser;
                    this.CreateTime = model.CreateTime;
                    this.AuditUser = model.AuditUser;
                    this.AuditTime = model.AuditTime;
                    this.CompleteTime = model.CompleteTime;
                    this.PayedMoney = model.PayedMoney;
            }
}
        protected override T_Purchase Inverter(Purchase model)
        {
            if (model != null)
            {
                return new T_Purchase()
                {
                    ID = model.ID,
                    PurchaseNumber = model.PurchaseNumber,
                    ProviderID = model.ProviderID,
                    SumAmount = model.SumAmount,
                    SumMoney = model.SumMoney,
                    State = model.State,
                    Remark = model.Remark,
                    CreateUser = model.CreateUser,
                    CreateTime = model.CreateTime,
                    AuditUser = model.AuditUser,
                    AuditTime = model.AuditTime,
                    CompleteTime = model.CompleteTime,
                    PayedMoney = model.PayedMoney,
                };
            }
            return null;
        }
        public Purchase Set(T_Purchase dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
